home *** CD-ROM | disk | FTP | other *** search
- /* stdef.h
- #
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
- This software is copyright (C) by the Lawrence Berkeley Laboratory.
- Permission is granted to reproduce this software for non-commercial
- purposes provided that this notice is left intact.
-
- It is acknowledged that the U.S. Government has rights to this software
- under Contract DE-AC03-765F00098 between the U.S. Department of Energy
- and the University of California.
-
- This software is provided as a professional and academic contribution
- for joint exchange. Thus, it is experimental, and is provided ``as is'',
- with no warranties of any kind whatsoever, no support, no promise of
- updates, or printed documentation. By using this software, you
- acknowledge that the Lawrence Berkeley Laboratory and Regents of the
- University of California shall have no liability with respect to the
- infringement of other copyrights by any part of this software.
-
- For further information about this notice, contact William Johnston,
- Bld. 50B, Rm. 2239, Lawrence Berkeley Laboratory, Berkeley, CA, 94720.
- (wejohnston@lbl.gov)
-
- For further information about this software, contact:
- Jin Guojun
- Bld. 50B, Rm. 2275,
- Lawrence Berkeley Laboratory, Berkeley, CA, 94720
- g_jin@lbl.gov
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- % Definitions for common types, NULL, and errno.
- %
- % AUTHOR: Jin Guojun - LBL 10/01/1990
- */
-
- #ifndef _STDDEF
- #define _STDDEF
-
- #if __STDC__
- #define _Cdecl
- #else
- #define _Cdecl cdecl
- #endif
-
- #if !defined FILE && !defined __STDIO_DEF_
- #include <stdio.h>
- #endif
- #ifndef SEEK_SET
- #define SEEK_SET 0
- #define SEEK_CUR 1
- #define SEEK_END 2
- #endif
- #define SEEK_GETB -1
- #define SEEK_UGETB -2
- #define SEEK_PEEK -3
-
-
- #ifdef TC_Need
- #ifndef _PTRDIFF_T
- #define _PTRDIFF_T
- #if defined(__LARGE__) | defined(__HUGE__) | defined(__COMPACT__)
- typedef long ptrdiff_t;
- #else
- typedef int ptrdiff_t;
- #endif
- #endif
- #ifndef NULL
- #if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
- #define NULL 0
- #else
- #define NULL 0L
- #endif
- #endif
-
- extern int _Cdecl errno;
-
- #else
-
- # ifndef coreleft
- # define coreleft() (MType)-1
- # endif
-
- extern int errno;
-
- #endif TC_Need
-
- #ifdef NO_CCSECL
- # define msg(s,a) fprintf(stderr, s, a)
- # define message(s,a,b) fprintf(stderr, s, a, b)
- #else
- # define msg message
- #endif
- #ifndef mesg
- #define mesg(s) fprintf(stderr, s)
- #endif
-
- #ifndef VType
- #define VType void
- #endif
- typedef void* VPointer;
-
- #ifndef PrtCAST
- #define PrtCAST (VType *)
- #endif
-
- #ifndef MIN
- # define MIN(a,b) ((a < b) ? a : b)
- #endif
-
- #ifndef isfloat
- #include <ctype.h>
- #define isfloat(c) (isdigit(c) || '+'<=c && c<='.' || toupper(c)=='E')
- #endif
-
- #define Stx 2
- #define Heart 3
- #define Diamond 4
- #define Club 5
- #define Spade 6
- #define Ack 6
- #define Bel 7
- #define BS 8
- #define Tab 9
- #define LF 10
- #define VT 11
- #define FmFd 12
- #define CR 13
- #define SO 14
- #define SI 15
- #define Esc 0x1B
- #define DC2 0x12
- #define DC4 0x14
- #define NAk 0x15
- #define CTRL_Y 0x19
- #define Space 0x20
- #define Del 0x7F
- #define GT_EQL 242
- #define ST_EQL 243
- #define RootS 251
-
- #define ByteMax 256
-
- #define TRUE 1
- #define FALSE 0
- #define Yes 1
- #define No 0
-
- #ifndef True
- #define True 1
- #define False 0
- #endif
-
-
- #if !defined HIPS2_HF
- typedef unsigned char byte;
- #endif
-
- #ifdef COMMON_TOOL
- # ifndef FITS_IMAGE
- # define FITS_IMAGE
- # endif
- # ifndef RLE_IMAGE
- # define RLE_IMAGE
- # endif
- #endif
-
- /* standard TYPE definitions */
- #ifndef MType
- # if defined TC_Need | defined INT_16_BIT
- # define MType long
- # else
- # define MType int
- # endif
- #endif
-
- #ifndef cmap_t
- #define cmap_t byte
- #endif
-
- typedef int bool;
- typedef unsigned int word;
- typedef unsigned int Pointer_Mem;
- typedef unsigned long longword;
- typedef short coord_t;
-
- /* definition for display attributes. */
- #define NoDpyB 0
- #define UnderLn 1
- #define Normal 7
- #define Reverse 0x70
- #define Blink 0x80
- #define HighLi 8
-
- #define ScrollUp 6
- #define ScrollDown 7
-
- /* The foot of a letter is lower than y0 in XDrawString() */
- #define XStringBaseHigh 4
-
- typedef struct {
- coord_t x0, y0, /* upper left corner position */
- cs, ls; /* Colunms and Lines */
- } Range;
-
- typedef struct {
- coord_t x, y, /* x & y are margin's offsets */
- width, height; /* screen display area height & width */
- } Offset;
-
- typedef union {
- struct {
- char line_w, fill, join, style;
- short angle1, angle2;
- } draw;
- struct {
- char font_id, fw, fh, fbsh, *content;
- } text;
- } si_union;
-
- typedef struct {
- coord_t x0, y0, w, h;
- long color;
- char e_type, hidden, cols, rows;
- si_union elem;
- } superimpose_elems;
-
- typedef struct {
- short stack_len, n_elems;
- superimpose_elems* stack;
- } superimpose_stack;
-
- typedef struct {
- char *base, /* buffer pointer. It should not be changed */
- *ptr; /* data pointer */
- MType bsize, /* buffer size */
- dlen; /* data size */
- int offset, /* header length */
- flags; /* buffer ID */
- } BUFFER;
-
- #define BUFFER_MAGIC 0xB99B5AA5 /* need to fit int and long */
- #define beof(bp) ((bp)->ptr - ((bp)->base + (bp)->offset) >= (bp)->dlen)
-
-
- #ifndef QSType
- #define QSType MType
- #endif
-
- typedef struct { /* for QuickSort */
- QSType value; /* sort dependent value */
- int QsIndex; /* can be any pointer */
- } QSCell;
-
- #define SoftInterface int
- typedef SoftInterface TableInterface;
- typedef SoftInterface StdInterface();
-
- typedef enum {
- ARGU_NONE = -1,
- ARGU_B0, /* #0 */
- ARGU_B1,
- ARGU_B2,
- ARGU_B3,
- ARGU_B4,
- ARGU_B5,
- ARGU_B6,
- ARGU_B7,
- ARGU_B8,
- ARGU_B9,
- ARGU_B10, /* #10 */
- ARGU_BNEG = '!', /* reserve 0B - 1F for other Bxxx */
- ARGU_BNEGI = '~', /* 0 if input is set; otherwise 1. */
- ARGU_BPLUS = '+',
- ARGU_BNUM = '#', /* True if input with number */
- ARGU_BMINUS = '-',
- ARGU_SCALE = '*',
- ARGU_BANDEF = '&', /* logic operation with default value */
- ARGU_BORDEF = '|',
- ARGU_BXORDEF = '^',
- ARGU_BEXTYPE = 'B', /* return extended argument type */
- ARGU_BEXT = 'E', /* return extension value */
- ARGU_BDEF = 'N', /* reset default value */
- ARGU_BOOL = 'b',
- ARGU_CHAR = 'c',
- ARGU_SHORT = 'h',
- ARGU_HEX = 'x',
- ARGU_INT = 'i',
- ARGU_FLOAT = 'f',
- ARGU_DOUBLE = 'g',
- ARGU_STRING = 's',
- ARGU_ADDPARAM = 127 /* flag should be "?-*" ;
- ? is any single character */
- } argu_type;
-
- typedef union {
- argu_type a;
- bool b;
- char c;
- short s;
- int i;
- float f;
- double d;
- } convs_v;
-
- typedef union {
- argu_type *a_p;
- bool *b_p;
- char *c_p,
- * *stp;
- short *s_p;
- int *i_p;
- float *f_p;
- double *d_p;
- void *v_p;
- } convs_p;
-
- typedef struct {
- argu_type type;
- convs_p p;
- convs_v v;
- } convs;
-
- typedef struct {
- char *flag, /* argument flag */
- *in_fmt; /* input format. */
- #ifdef USE_STRING_ARGU_DEF
- char* def_val; /* no defined variable can be passed */
- #else
- float def_val; /* no double value for default. */
- #endif
- int num_vars,
- min_inps; /* min input(s) for above variables */
- char *info;
- bool sscan;
- } arg_fmt_list_string;
-
- typedef struct e_afls {
- arg_fmt_list_string *fls;
- int flag_len,
- u_l_s,
- extended_flags,
- ext_level; /* root=0, 1st_ext=1, 2nd_ext=2, ... */
- convs *v;
- struct e_afls *extend;
- } arg_fmt_lists;
-
-
- #ifdef WINDOW_VER
-
- # include <dos.h>
- typedef union REGS Regset;
- # include <keycode.h>
- # define WaitKey() while (!kbhit())
-
- #endif
-
- extern bool _debug, debug, prgmerr();
- extern char *strcpy(), *strncpy();
- extern double arget();
- extern VType *nzalloc(), *zalloc();
-
- #define Loop while(1)
-
- #ifndef DEBUGANY
- #define DEBUGANY debug
- #endif
-
- #define DEBUG_L2 (DEBUGANY==2)
- #define DEBUG_L3 (DEBUGANY==3)
- #define DEBUG2OH (DEBUGANY > 1)
- #define DEBUG3OH (DEBUGANY > 2)
- #define DEBUGMESSAGE if (DEBUGANY) message
- #define DEBUG2MESSAGE if (DEBUG2OH) message
-
- #define NS_TSET(r, c, type) avset(argc, argv, r, c, type)
-
- #define Alloc_Mem(ahow, i, j, ms) \
- PrtCAST(i*j ? core_trace(coreleft(), ahow, i, j, ms) : 0)
- #define NZALLOC(i, j, ms) Alloc_Mem(malloc((i) * (j)), i, j, ms)
- #define ZALLOC(i, j, ms) Alloc_Mem(calloc(i, j), i, j, ms)
- #define pointer_buffer_size(p) (*((int *)p - 2) - (sizeof(int) << 1))
-
- #ifndef str_save
- #define str_save(s) strcpy(ZALLOC((MType)(strlen(s)+1), (MType)1, s), s)
- #endif
-
- #if defined TC_Need & !defined _SIZE_T
- # define _SIZE_T
- typedef unsigned size_t;
- #endif
- #ifdef sparc
- extern fclose(), fread(), fwrite();
- extern int fseek();
- #endif
-
- /* for reading a stream to work with fseek, fgetc, and ungetc */
- #define init_readpipe(i) set_readpipe(i, True)
- #define reset_readpipe(i) set_readpipe(i, False)
- #define pushpipe(buf, size, fp) readpipe(buf, -1, size, fp)
-
- #endif _STDDEF
-